<?php
/* @var $this UsersController */
/* @var $model Users */

$this->breadcrumbs=array(
	'Users'=>array('index'),
	'Manage',
);

$this->menu=array(
	array('label'=>'List Users', 'url'=>array('index')),
	array('label'=>'Create Users', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#users-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Users</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
));
    $listGh = Gh::model()->findAll(array('select'=>'id,name'));
    if(isset($_GET['Users']['gh_id']) && !empty($_GET['Users']['gh_id']))
        $listGx = Gx::model()->findAll('gh_id=:gh_id', array(':gh_id'=>$_GET['Users']['gh_id']), array('select'=>'id,name'));
    else
        $listGx = Gx::model()->findAll(array('select'=>'id,name'));
    $listLevel = Level::model()->findAll(array('select'=>'id,name'));

?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'users-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
        array(
            'name'=>'gh_id',
            'value'=>'$data->gh->name',
            'filter'=>CHtml::listData($listGh, 'id', 'name'),
            'htmlOptions' => array('width'=>'10%'),
        ),
        array(
            'name'=>'gx_id',
            'value'=>'$data->gx->name',
            'filter'=>CHtml::listData( $listGx, 'id', 'name'),
            'htmlOptions' => array('width'=>'10%'),
        ),
        array(
            'name'=>'current_level',
            'value'=>'$data->level->name',
            'filter'=>CHtml::listData($listLevel, 'id', 'name'),
            'htmlOptions' => array('width'=>'10%'),
        ),
        /*array(
            'name'=>'photo',
            'filter'=>false
        ),*/
        array(
            'header'=>'Name',
            'value'=>'$data->firstname ." ". $data->lastname',
            'htmlOptions' => array('width'=>'20%'),
        ),
		array(
            'header'=>'Email',
            'name'=>'email',
            'filter'=>false,
            'htmlOptions' => array('width'=>'15%'),
        ),
		array(
            'name'=>'address',
            'filter'=>false,
            'htmlOptions' => array('width'=>'15%'),
        ),
        array(
            'name'=>'date_created',
            'filter'=>false,
            'htmlOptions' => array('width'=>'12%'),
        ),
		array(
            'header'=>'Action',
			'class'=>'CButtonColumn',
		),
	),
)); ?>
